<div class="container">
  <div class="row row-cards row-deck mt-md-5">

    <div class="col-md-3">
<%= render "_sidebar.html", assigns %>
    </div>
    
    <div class="col-md-9">
      <div class="card" style="flex-grow: 0;">
        <div class="table-responsive">
          <table class="table table-hover table-outline table-vcenter text-nowrap card-table">
            <thead>
              <tr>
                <th ><%= gettext "Title" %></th>
                <th><%= gettext "Category" %></th>
                <th class="text-center"><%= gettext "Published at" %></th>
                <th class="text-center"></th>
              </tr>
            </thead>
            <tbody>

              <%= for post <- @posts do %>
                <tr>
                  <td> <a href="<%= Routes.post_path(@conn, :show, post) %>" class=""><%= post.title %></a>
                  </td>

                  <td>
                    <%= for category <- post.categories do %>
                      <span class="badge badge-secondary"><%= category.name %></span>
                    <% end %>
                  </td>


                  <td class="text-center">
                    <%= if post.draft do %>
                      <span class="badge badge-pill badge-secondary"><%= gettext "Draft" %></span>
                    <% else %>
                      <%= format_date(post.date) %>
                    <% end %>
                  </td>

                  <td class="text-center">
                    <div class="item-action dropdown">
                      <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
                      <div class="dropdown-menu dropdown-menu-right">
                        <!-- <a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> Publish </a> -->
                        <a href="<%= Routes.post_path(@conn, :edit, post) %>" class="dropdown-item"><i class="dropdown-icon fe fe-edit-2"></i> Edit</a>
                        <%= link to: Routes.post_path(@conn, :delete, post), class: "dropdown-item", method: "delete", data: [confirm: gettext("Are you sure?")] do %>
                          <i class="dropdown-icon fe fe-x"></i> <%= gettext "Delete" %></a>
                        <% end %>
                      </div>
                    </div>
                  </td>
                </tr>
              <% end %>

            </tbody>
          </table>

        </div>
      </div>

      <%= component "pagination.html", assigns %>

    </div>

  </div>
</div>




